﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using DataHelper;
using Utils;
namespace DAL
{
   public class GroupDao
    {
        public bool Insert(string tableName, SortedDictionary<string, string> sdList)
        {
            return new BuiltSQL().InsertTable(tableName, sdList);
        }
        public bool Update(string tableName, SortedDictionary<string, string> sdList)
        {
            return new BuiltSQL().UpdateTable(tableName, sdList);
        }
        public string Delete(string tableName, string[] primaryKey)
        {
            return new BuiltSQL().DeleteTable(tableName, primaryKey);
        }

        #region Gruop
        public DataTable GetGroupOne(string groupID)
        {
            return SQLHelper.ExecuteSqlGetDrToDt("Select * from Sys_Group Where  GroupID=" + groupID);
        }
        public DataTable GetGroupLists(string account, string gType, string key, bool right)
        {           
            string sql = "Select * from Sys_Group Where GType like '%" + gType + "%' ";
            if (right)
            {
                sql += " and Account='" + account + "'";
            }
            if (key != "") sql += " and GName like '%" + key+"%'";
            sql += " order by AbsIndex";
            return SQLHelper.ExecuteSqlGetDrToDt(sql);
        }
        #endregion 
        #region GruopUser
        public DataTable GetGUserLists(string groupID)
        {
            return SQLHelper.ExecuteSqlGetDrToDt("Select * from Sys_GroupUser Where  GroupID=" + groupID);
        }
        #endregion
    }
}
